﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Windows;
using System.Windows.Controls;
using System.Windows.Data;
using System.Windows.Documents;
using System.Windows.Input;
using System.Windows.Media;
using System.Windows.Media.Imaging;
using System.Windows.Navigation;
using System.Windows.Shapes;

namespace PomodoroTool
{
    using System.Collections.ObjectModel;

    /// <summary>
    /// Interaction logic for TaskItem.xaml
    /// </summary>
    public partial class TaskItem : UserControl
    {
        protected ObservableCollection<BitmapImage> PomodoroStat = new ObservableCollection<BitmapImage>();

        public TaskItem()
        {
            InitializeComponent();
            taskBadges.ItemsSource = PomodoroStat;
        }

        public void AddPomodoro()
        {
            PomodoroStat.Add((BitmapImage)this.rootGrid.Resources["pomodoro"]);
        }

        public void AddDone()
        {
            PomodoroStat.Add((BitmapImage)this.rootGrid.Resources["done"]);
        }

        public void AddPomodoro(int pomodoros)
        {
            for (int i = 0; i < pomodoros; i++)
            {
                this.AddPomodoro();
            }
        }

        private void UserControl_MouseUp(object sender, MouseButtonEventArgs e)
        {
            this.InvokeMyMouseUp();
        }

        public event Action MyMouseUp;

        public void InvokeMyMouseUp()
        {
            Action handler = this.MyMouseUp;
            if (handler != null)
            {
                handler();
            }
        }
    }
}
